package com.easy_helth.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.easy_helth.common.R;
import com.easy_helth.entity.Resource;
import com.easy_helth.service.ResourceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/home")
public class RecourseController {
    @Autowired
    ResourceService resourceService;

//    获取swiper数据
    @GetMapping("/getSwiper")
    public R<List<Resource>> getSwiper(Resource resource) {
        LambdaQueryWrapper<Resource> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(Resource::getSort , 1 );
        List<Resource> resourcesList = resourceService.list(lambdaQueryWrapper);
        return R.success(resourcesList);
}

//获取分类分类导航数据
//    获取swiper数据
@GetMapping("/catitems")
public R<List<Resource>> getCatitems(Resource resource) {
    LambdaQueryWrapper<Resource> lambdaQueryWrapper = new LambdaQueryWrapper<>();
    lambdaQueryWrapper.eq(Resource::getSort,2);
    List<Resource> resourcesList = resourceService.list(lambdaQueryWrapper);
    return R.success(resourcesList);
}

    /**
     *获取floor层数据
     * @return
     */
    @GetMapping("/floorData")
    public R<List<Resource>> getFloors() {
        log.info("获取floor成功");
        LambdaQueryWrapper<Resource> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(Resource::getSort,3);
        List<Resource> resourcesList = resourceService.list(lambdaQueryWrapper);
        return R.success(resourcesList);
    }

    /**
     *获取floor层数据
     * @return
     */
    @GetMapping("/floorData2")
    public R<List<Resource>> getFloors2() {
        log.info("获取floor成功");
        LambdaQueryWrapper<Resource> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(Resource::getSort,4);
        List<Resource> resourcesList = resourceService.list(lambdaQueryWrapper);
        return R.success(resourcesList);
    }

}
